package com.hmy.park.controller;

import com.hmy.park.domain.HmyParkType;
import com.hmy.park.service.ParkTypeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author ljy
 * @Date 2024/1/29 15:56
 * @description: 园区类型
 * @Title: HmyParkTypeController
 * @Package com.hmy.pig.controller
 */
@Api(value = "/park", tags = {": 园区类型"})
@RestController
@RequestMapping("/park")
public class ParkTypeController extends BaseController {
    @Resource
    private ParkTypeService parkTypeService;

    /**
     * @return com.ruoyi.common.core.web.domain.AjaxResult
     * @description 园区类型列表
     * @author ljy
     * @date 2024/1/29 18:06:48
     */
    @ApiOperation(value = "园区类型列表", notes = "园区类型列表", httpMethod = "GET")
    @RequiresPermissions("hmy:park:list")
    @GetMapping("/find")
    public TableDataInfo findlist() {
        startPage();
        List<HmyParkType> parkTypeList = parkTypeService.findParkTypeList();
        return getDataTable(parkTypeList);
    }

    /**
     * @param hmyParkType
     * @return com.ruoyi.common.core.web.domain.AjaxResult
     * @description 添加园区类型
     * @author ljy
     * @date 2024/1/29 19:30:40
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "HmyParkType", name = "hmyParkType", value = "", required = true)
    })
    @ApiOperation(value = "添加园区类型", notes = "添加园区类型", httpMethod = "POST")
    @RequiresPermissions("hmy:park:save")
    @PostMapping("save")
    public AjaxResult save(@RequestBody HmyParkType hmyParkType) {
        Integer i = parkTypeService.saveParkType(hmyParkType);
        return toAjax(i);
    }

    /**
     * @param hmyParkType
     * @return com.ruoyi.common.core.web.domain.AjaxResult
     * @description 修改园区类型
     * @author ljy
     * @date 2024/1/29 19:46:41
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "HmyParkType", name = "hmyParkType", value = "", required = true)
    })
    @ApiOperation(value = "修改园区类型", notes = "修改园区类型", httpMethod = "POST")
    @PostMapping("update")
    public AjaxResult update(@RequestBody HmyParkType hmyParkType) {
        Integer i = parkTypeService.updateParkById(hmyParkType);
        return toAjax(i);
    }

    /**
     * @param parkId
     * @return com.ruoyi.common.core.web.domain.AjaxResult
     * @description 根据id删除
     * @author ljy
     * @date 2024/1/29 19:52:59
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "long", name = "parkId", value = "", required = true)
    })
    @RequiresPermissions("hmy:park:del")
    @ApiOperation(value = "根据id删除", notes = "根据id删除", httpMethod = "POST")
    @PostMapping("del/{parkId}")
    public AjaxResult delByid(@PathVariable(value = "parkId") Long parkId) {
        Integer i = parkTypeService.delParkById(parkId);
        return toAjax(i);
    }
}
